package com.yunhe.java.Day09;

import java.util.Arrays;

/**
 * Created by Administrator on 2017/8/2 0002.
 */
public class StringDemo {
    public static void main(String[] args) {
        String a="asdgfghgh";
        int [] b={1,2,3,5,6};
        char[] chars=a.toCharArray();
        for(char aa:chars){
            System.out.print(aa+" ");
        }
        System.out.println();
        boolean c=a.isEmpty();
        System.out.print(a+"是否为空："+c+" ");
        String a1="";
        for(int aa:b){
            System.out.print(aa+a1);
        }
        System.out.println();
        System.out.print(a+"字符长度是："+a.length()+" ");

        byte[] b1=a.getBytes();
        System.out.println("转为byte数组："+Arrays.toString(b1));
        //找到 某个字符的索引（从0开始）
        System.out.println( a.indexOf('h'));
        //拼接
        System.out.println(a.concat("DDDD"));
        //截取剩余的字符
        System.out.println(" "+a.substring(2));
        //截取某一段字符（a s d g）
        System.out.println(a.substring(0,4));
        //切割
        String [] aa =a.split("g");
        System.out.println(Arrays.toString(aa));
        //替换单个字符
        System.out.println(a.replace('g','G'));
        //替换字符串
        System.out.println(a.replace("sd","SD"));





    }
}
